package com.milasoft.queueingcloud;

import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseObject;
import com.parse.ParseUser;

import android.support.v7.app.ActionBarActivity;
import android.app.ActionBar;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
	static String userLogin;
	static String passwordLogin;
	
	@Override
	
	protected void onCreate(Bundle savedInstanceState) {
		Parse.enableLocalDatastore(this);
		 
		Parse.initialize(this, "xGINKjsGglkQbELaXkisDbU0weQZ1x0xTOMjm8BJ", "KaZNDskAak6LJUCjLyKe745cxr8g6QCF8WiIVh1Z");
		
		/*ParseObject testObject = new ParseObject("QueueingTable");
		testObject.put("UserName", "ceren");
		testObject.saveInBackground(); */
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_main);
	
		final TextView userName = (TextView) findViewById(R.id.username);
		final TextView passWord = (TextView) findViewById(R.id.password);
	
		

		Button button = (Button) findViewById(R.id.login);
		button.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				userLogin = (String) userName.getText().toString();
				passwordLogin = (String) passWord.getText().toString();
				if ((userLogin.equalsIgnoreCase("merve")) && (passwordLogin.equalsIgnoreCase("2112"))) {
					Intent userPageActivity = new Intent(MainActivity.this,
							UserPageActivity.class);
					startActivity(userPageActivity);

				} else if ((userLogin.equalsIgnoreCase("tugce"))
						&& (passwordLogin.equalsIgnoreCase("3010"))) {
					Intent adminPageActivity = new Intent(MainActivity.this,
							AdminPageActivity.class);
					startActivity(adminPageActivity);
				}
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
